import { request } from "@/utils/requst"

Page({
    onShow(){
        this.getSelfMail()
    },
    data: {
        mailList: [
        ]
    },
    goWrite(){
        wx.navigateTo({url: '/pages/write/write'})
    },
    async getSelfMail(){
       const res:any =  await request('GET', '/sendMail/findSelfMail')
        this.setData({
            mailList:res.data.data
        })
    },
    async handleDelete(e) {
        const id:number = e.currentTarget.dataset.id
        const result:any = await request('GET', `/sendMail/remove/${id}`)
        if (result.data.status) {
            wx.showToast({
                title: '取消成功！',
                icon: 'success'
            })
        }
        this.getSelfMail()
    },
    async getMailInfo(e) {
        const {id,type} = e.currentTarget.dataset
        wx.navigateTo({
            url: `/pages/write/write?id=${id}&type=${type}`,
        })
    }
})